*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* McIlwain and Caliendo 2008 and 2010 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data for the 2010 survey available here: http://www.tessexperiments.org/data/mcilwain787.html
*******************************************************************************************************************************
*******************************************************************************************************************************

*******************************************************************************************************************************
*** Open the 2008 dataset
*******************************************************************************************************************************

* use "TESS109_Mcllwain_Final_data.dta", clear
set more off

* These variables will be used and are the same for the 2008 and 2010 datasets:
* Q1, Q5, Q6

* These variables will be renamed to match the 2010 dataset variables:
rename Q4_2 Q4b
rename Q4_1 Q4a
rename Q3 Q3B
rename Q2 Q3A
rename Q1b Q2
rename XTESS109 XTESS025
rename CaseID caseid
replace caseid = caseid + 1000
sum caseid

merge 1:1 caseid using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\8-mcilwain and caliendo 2010\tess2_025_mcilwain_final_data.dta"
tab _merge

*******************************************************************************************************************************
*** Racial groups
*******************************************************************************************************************************

tab PPETHM
tab PPETHM, nol
gen whiteR = PPETHM
recode whiteR (2=0)
gen blackR = PPETHM
recode blackR (1=0) (2=1)
tab PPETHM whiteR
tab PPETHM blackR

*******************************************************************************************************************************
*** Treatments
*******************************************************************************************************************************

tab XTESS025
gen blackH = XTESS025
recode blackH (1 2=0) (5 6=1)
tab XTESS025 blackH
gen lownumber1st = 0
recode lownumber1st (0=1) if XTESS025==1 | XTESS025==3 | XTESS025==5 | XTESS025==7
tab XTESS025 lownumber1st

*******************************************************************************************************************************
*** Sample restrictions
*******************************************************************************************************************************

* Chapter 2
* Ads 1/2: Jackson black, Herbert white w/ no racial appeal.
* Ads 1/3: Jackson black, Herbert white w/ anti-black appeal.

* Chapter 3
* Ads 4/5: Jackson black, Herbert black w/ no racial appeal.
* Ads 4/6: Jackson black, Herbert black w/ authencity appeal.

*******************************************************************************************************************************
*** Outcome variables
*******************************************************************************************************************************

tab Q1
gen vH = Q1
recode vH (-1 1=0) (2=1)
tab Q1 vH, mi

sum Q3A Q3B
gen ftH = Q3B - Q3A
sum ftH

sum Q4a Q4b
gen idealH = Q4a - Q4b
sum idealH

alpha vH ftH idealH, min(2) std item gen(ALPHA)
pwcorr vH ftH idealH ALPHA

sum ALPHA if whiteR==1
di r(sd)
gen ov_white_std = ALPHA/r(sd) if whiteR==1

sum ALPHA if blackR==1
di r(sd)
gen ov_black_std = ALPHA/r(sd) if blackR==1

*******************************************************************************************************************************
*** Racial manipulation check
*******************************************************************************************************************************

// No racial manipulation check

*******************************************************************************************************************************
*** Main regressions [Unweighted]
*******************************************************************************************************************************

reg ov_white_std blackH lownumber1st if whiteR==1 & (XTESS025==1 | XTESS025==2 | XTESS025==5 | XTESS025==6)
reg ov_black_std blackH lownumber1st if blackR==1 & (XTESS025==1 | XTESS025==2 | XTESS025==5 | XTESS025==6)
